<?php
include 'session.php';
require 'free.php';

mysql_connect('localhost', 'root');
mysql_select_db('dots');

$userID = $_SESSION['userID'];
if (empty($_GET['requestID']))
{
header('location:../requests.php');
exit;
}
$requestID = $_GET['requestID'];
$reg = '/[0-9]{1,16}/';
if (!preg_match($reg, $requestID))
{
	header('location:../requests.php');
	exit;
}

$query = "UPDATE requests SET guestID=$userID WHERE requestID=$requestID AND guestID IS NULL AND autorID<>$userID";
$res = mysql_query($query);

header('location:../requests.php');
?>